<?php

namespace app\common\dao\system;

use app\common\model\system\AdminLog as model;
use app\common\dao\BaseDao;

class AdminLogDao extends BaseDao
{
    /**
    * 设置模型
    * @return model
    */
    protected function getModel(): string
    {
        return model::class;
    }

    public function search(array $where)
    {
        $query = ($this->getModel())::getDB()->when(isset($where['date']) && $where['date'] !== '', function ($query) use ($where) {
            getModelTime($query, $where['date']);
        });
        if (isset($where['method']) && $where['method'] !== '') $query->where('method', $where['method']);
        if (isset($where['admin_id']) && $where['admin_id'] !== '') $query->where('admin_id', $where['admin_id']);
        if (isset($where['section_startTime']) && $where['section_startTime'] && isset($where['section_endTime']) && $where['section_endTime'])
            $query->where('create_time', '>', $where['section_startTime'])->where('create_time', '<', $where['section_endTime']);

        return $query;
    }

}